package edu.purdue.cs.ds.vss;

import java.math.BigInteger;
import java.util.ArrayList;

public class IndexSets {
 
	public ArrayList<ArrayList<Integer>> generateIndexSets(int n, ArrayList<ArrayList<Integer>> serverSets) {
		ArrayList<ArrayList<Integer>> indexSets = new ArrayList<ArrayList<Integer>>();
		for(int i = 0; i < n; i++) {
			ArrayList<Integer> set = new ArrayList<Integer>();
			for(int j = 0; j < serverSets.size(); j++) {
				ArrayList<Integer> shareSet = serverSets.get(j);
				if(!shareSet.contains(new Integer(i))) {
					set.add(new Integer(j));
				}
			}
			indexSets.add(set);
			
		}
		
		return indexSets;
	}
	
	
	public ArrayList<ArrayList<BigInteger>> generateShareSets(int n, ArrayList<BigInteger> shares,
																ArrayList<ArrayList<Integer>> serverSets){
		
		ArrayList<ArrayList<BigInteger>> serverShares = new ArrayList<ArrayList<BigInteger>>();
		for(int i = 0; i < n; ++i)
			serverShares.add(new ArrayList<BigInteger>());
		
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < shares.size(); ++j){
				if(!serverSets.get(j).contains(i))
					serverShares.get(i).add(shares.get(j));
			}
		}
		
		
		return serverShares;
	}
	
	public ArrayList<ArrayList<Share>> generateShareSets2(int n,
			ArrayList<Share> shares, ArrayList<ArrayList<Integer>> serverSets) {

		ArrayList<ArrayList<Share>> serverShares = new ArrayList<ArrayList<Share>>();
		
		for(int i = 0; i < n; ++i) {
			serverShares.add(new ArrayList<Share>());
		}
		
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < shares.size(); ++j){
				if(!serverSets.get(j).contains(i)) {
					ArrayList<Share> arrayList = serverShares.get(i);
					arrayList.add(shares.get(j));
					
				}
			}
		}
		
		return serverShares;
	}
	
}
